/*
 * PhysicalObject.cpp
 *
 *  Created on: Aug 10, 2009
 *      Author: Weston Wedding
 */

#include "PhysicalObject.h"

PhysicalObject::PhysicalObject():
    unitOrientation(0.0f, 0.0f, 0.0f),
    mass(0.0f),
    pitchSpeed(0.0f),
    yawSpeed(0.0f),
    rollSpeed(0.0f),
    airDensity(0.0f),
    dragCoefficient(0.0f),
    liftCoefficient(.0f),
    airSpeed(0.0f,0.0f,0.0f),
    referenceArea(.0f),
    thrust(0.0,0.0,0.0f),
    lift(0.0f,0.0f,0.0f),
    drag(0.0f,0.0f,0.0f),
    weight(0.0f,0.0f,0.0f),
    netForce(0.0f,0.0f,0.0f),
    special1(0.0f,0.0f,0.0f),
    special2(0.0f,0.0f,0.0f),
    pitch(0.0f),
    yaw(0.0f),
    roll(0.0f),
    coordinates(),
    angleOfAttack(0.0f),
    groundSpeed(0.0f,0.0f,0.0f)
{
}

PhysicalObject::PhysicalObject(scalar x, scalar y, scalar z, PhysicalProperties properties)
{
}

PhysicalObject::~PhysicalObject()
{

}

Vector PhysicalObject::calculateNetForce()
{
    return thrust + lift + drag + weight;
}

Vector PhysicalObject::calculateThrustForce()
{
    return thrust;
}

Vector PhysicalObject::calculateLiftForce()
{
    return liftCoefficient * getDynamicPressure() * referenceArea;
}

Vector PhysicalObject::calculateDragForce()
{
    return dragCoefficient * getDynamicPressure() * referenceArea;
}

Vector PhysicalObject::calculateWeightForce()
{
    return weight;
}

bool PhysicalObject::setAirDensity(float density)
{
    airDensity = density;
    return true;
}
bool PhysicalObject::setAirSpeed(Vector airSpeed)
{
    airSpeed = airSpeed;
    return true;
}
bool PhysicalObject::setGroundSpeed(Vector groundSpeed)
{
    groundSpeed = groundSpeed;
    return true;
}

Vector PhysicalObject::getDynamicPressure()
{
    return (cross(airSpeed, airSpeed) * airDensity)/ 2;
}
